Method and apparatus for adjusting the contrast of an image

ABSTRACT

A method and apparatus for adjusting the contrast of an image, in which each pixel in the image has an initial brightness level that is within a range of brightness levels between a minimum brightness level and a maximum brightness level. For each brightness level within the range, the number of pixels that have the same initial brightness level is counted. The pixels are divided into at least two types by identifying the or each set of pixels having initial brightness levels in which each of a plurality of adjacent ones of said brightness levels has more pixels than a threshold number. The pixels of the plurality of adjacent ones of said brightness levels are treated as a first type. The remaining pixels are treated as a second type. For the or each set of pixels of the first type, contrast enhancement is carried out separately on those pixels.

CROSS-REFERENCE TO RELATED APPLICATIONS

Not applicable.

STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT

Not applicable.

TECHNICAL FIELD OF THE INVENTION

The present invention relates to a method and apparatus for adjustingthe contrast of an image.

BACKGROUND OF THE INVENTION

A number of techniques are known for adjusting the contrast of an image,particularly in order to improve the contrast and therefore visibilityof the image. Contrast adjustment or enhancement of images, particularlydigital images, is used in many fields, including enhancing the contrastof a digital image for display by a television receiver or other displaydevice, for printing by a printer, in digital cameras, etc., etc.Contrast enhancement is used to improve the contrast in medical andother images.

A known technique is so-called histogram equalisation. A discussion ofhistogram equalisation can be found in for example “Digital ImageProcessing”, Prentice Hall, New Jersey, 2001, by R. C. Gonzalez &Richard E. Woods. Histogram equalisation is based on the assumption thatan image having good contrast has pixels having brightness levels thatare generally equally distributed over the range of possible brightnesslevels that can be displayed by the display device, printed by theprinter, etc. Individual pixels retain their brightness order (i.e. theyremain brighter or darker than other pixels) . However, the values ofthe brightness levels of the individual pixels are adjusted so that theyare equally distributed over the brightness scale.

Referring to FIG. 1, in histogram equalisation the brightness levels ofthe input digital image are subject to histogram generation 1 in which ahistogram of the brightness levels of the pixels is generated. Then acumulative distribution function is generated from the histogram 2. Thecumulative distribution function is normalised as necessary to theavailable dynamic range of the display device, printer, etc. Forexample, the dynamic range may have 256 grey levels. This normalisedcumulative distribution function is then used to map the brightnesslevels of the input digital image to brightness levels of an outputimage 3, which can then be passed for display, printing, etc. Histogramequalisation enhances the contrast for brightness values that are closeto maxima in the histogram and decreases contrast near the minima. Inother words, histogram equalisation improves the contrast in the imagein areas of poor contrast at the expense of those areas where there isalready good contrast.

A particular limitation of histogram equalisation is that large peaks inthe histogram can be caused by large areas of similar brightness.Frequently, these correspond to areas of background which are oftenuninteresting. In any event, the effect of histogram equalisation can beover-enhancement and increased noise visibility. In the case where thehistogram contains tall peaks, the generated cumulative distributionfunction becomes steep and brightness levels in the input image that areclose to each other can be mapped to output brightness levels that arefar from each other.

A number of techniques for overcoming this over-enhancement problem areknown. For example, a modified cumulative distribution function isdisclosed in “Adaptive Image Contrast Enhancement Using Generalizationsof Histogram Equalization”, by J. Alex Stark in IEEE Transactions onImage processing, vol. 9, no. 5, May 2000. Referring to FIG. 2, thegenerated histogram 4 is subject to a modified cumulation function 5that weighs the histogram values. This weighing function is inverselyproportional to the distance from the current pixel brightness level. Inthis way, large changes in the cumulation function 5 are avoided, suchthat the mapping 6 does not change the characteristics of the imageseverely. Nevertheless, a problem with this modified technique is thatthe weighing functions must be chosen in advance, and no single weighingfunction is sufficient to create a mapping that will avoidover-enhancement for all images. For example, for an input image thathas extremely narrow peaks in the histogram of brightness levels, theweighing function must be adjusted accordingly. However, adjusting theweighing function to deal with narrowly peaked histograms will not givesatisfactory visual results when the histogram is not narrowly peakedand the dynamic range is wider.

SUMMARY OF THE INVENTION

According to a first aspect of the present invention, there is provideda method of adjusting the contrast of an image formed of pixels in whicheach pixel has an initial brightness level that is within a range ofbrightness levels between a minimum brightness level and a maximumbrightness level, the method comprising, for at least some of the pixelsin the image: for each of the brightness levels within said range,counting the number of said pixels that have the same initial brightnesslevel; dividing said pixels into at least two types by identifying theor each set of pixels having initial brightness levels in which each ofa plurality of adjacent ones of said brightness levels has more pixelsthan a threshold number, the pixels of said plurality of adjacent onesof said brightness levels being a first type, the remaining pixels beinga second type; and, separately for the or each set of pixels of thefirst type, performing contrast enhancement on the pixels that make upthe set.

Thus, the pixels are (notionally) divided into at least first and secondtypes. The first type are the pixels that have initial brightness levelsthat are “clustered” and each contain more pixels than the thresholdnumber. In other words, where for example a histogram of the initialbrightness levels of the pixels is formed, the histogram is divided intoone or more contiguous “Type I” regions in which each adjacentbrightness level contains more pixels than the threshold number. TheseType I regions indicate the presence of dominant objects in the imageand thus the regions where contrast enhancement is preferentiallyapplied. Contrast enhancement is then carried out on the pixels of theType I regions, the pixels of each Type I region being treatedseparately, and most preferably with contrast enhancement techniquesthat differ in detail and that are tailored to the characteristics ofthe pixels making up each Type I region.

In a preferred embodiment, the contrast enhancement that is performed onthe pixels that make up the or each set of pixels of the first type ishistogram equalisation.

The method may be carried out on all pixels in the image.

In the counting step, a histogram may be formed in which the number ofpixels per brightness level is indicated, the method comprisingsmoothing said histogram prior to the dividing step. This smoothinghelps to overcome the problem of histogram skew, which can arise forexample because of quantisation when the image is initially digitised.The smoothing may be carried out by passing the values of the histogramthrough a low pass filter. The minimum and maximum brightness levels insaid histogram after smoothing are preferably the same as the maximumand minimum initial brightness levels of said pixels.

The threshold number is preferably the average of the number of pixelsper brightness level obtained in the counting step multiplied by aconstant greater than 0 and less than or equal to 1. Typically, theconstant is 1 though other values for the constant may be set. Indeed,other ways of determining the threshold are available.

In an embodiment, a linear transformation is applied to the initialbrightness levels of the pixels of the second type. In this embodiment,the brightness levels pixels of the second type are thus subject tosimple adjustment as necessary.

Preferably the method comprises, prior to the contrast enhancement step,expanding the range of brightness levels in the or each set of pixels ofthe first type. This helps to improve the contrast in the dominantobjects indicated by these pixels being of the first type.

The method may comprise expanding the range of brightness levels in theor each set of pixels of the first type by a factor (1+g.L_R/D_R), whereg is a scalar multiplier, L_R is the range of brightness levels in theset and D_R is a measure of the dynamic range of brightness levels inthe image.

D_R may be defined as (1+P_MAX−P_MIN) where P_MAX is the maximumbrightness level and P_MIN is the minimum brightness level.

More preferably, however, D_R is defined as (1+P_MAX−P_MIN) where P_MAXis the maximum initial brightness level and P_MIN is the minimum initialbrightness level exhibited by at least a predetermined percentage ofsaid pixels, said predetermined percentage being less than 100%.Alternatively, preferably D_R is defined as (1+P_MAX−P_MIN) where P_MINis the minimum initial brightness level and P_MAX is the maximum initialbrightness level exhibited by at least a predetermined percentage ofsaid pixels, said predetermined percentage being less than 100%. Mostpreferably, D_R is defined as (1 +P_MAX−P_MIN), where P_MIN is theminimum initial brightness level exhibited by at least a firstpredetermined percentage of said pixels, and P_MAX is the maximuminitial brightness level exhibited by at least a second predeterminedpercentage of said pixels, said first predetermined percentage beingless than said second predetermined percentage and each of the first andsecond predetermined percentages being less than 100%. In any of thesepreferred embodiments, the dynamic range is made more robust to noiseand better captures the actual dynamic range, especially if the tails ofthe histogram are small.

In an embodiment, said image is one image of a succession of images, themethod being applied to the images of the succession of images using thesame contrast enhancement until a sufficient change in the contrast ofthe images is detected, when a different contrast enhancement is appliedto further images of the succession of images. Thus, for example, thesame mapping for contrast enhancement can be used until a significant orsufficient scene change is detected.

According to a second aspect of the present invention, there is providedapparatus for adjusting the contrast of an image formed of pixels inwhich each pixel has an initial brightness level that is within a rangeof brightness levels between a minimum brightness level and a maximumbrightness level, the apparatus comprising: a counter constructed andarranged to count, for at least some of the pixels in the image and foreach of the brightness levels within said range, the number of saidpixels that have the same initial brightness level; a classifierconstructed and arranged to divide said pixels into at least two typesby identifying the or each set of pixels having initial brightnesslevels in which each of a plurality of adjacent ones of said brightnesslevels has more pixels than a threshold number, the pixels of saidplurality of adjacent ones of said brightness levels being a first type,the remaining pixels being a second type; and, a contrast enhancerconstructed and arranged to perform contrast enhancement separately onthe or each set of pixels of the first type.

In a preferred embodiment, the contrast enhancer is arranged such thatthe contrast enhancement that is performed on the pixels that make upthe or each set of pixels of the first type is histogram equalisation.

The apparatus may be arranged to operate on all pixels in the image.

The counter may be arranged to form a histogram in which the number ofpixels per brightness level is indicated, the apparatus comprising asmoother constructed and arranged to smooth said histogram prior tooperation of the classifier. The smoother may be arranged to operate bypassing the values of the histogram through a low pass filter. Thesmoother is preferably arranged so that the minimum and maximumbrightness levels in said histogram after smoothing are the same as themaximum and minimum initial brightness levels of said pixels.

The threshold number is preferably the average of the number of pixelsper brightness level obtained in the counting step multiplied by aconstant greater than 0 and less than or equal to 1.

In an embodiment, the apparatus comprises a contrast enhancerconstructed and arranged to apply a linear transformation to the initialbrightness levels of the pixels of the second type.

The apparatus may comprise a range expander constructed and arranged toexpand the range of brightness levels in the or each set of pixels ofthe first type prior to operation of the contrast enhancer.

The range expander may be arranged to expand the range of brightnesslevels in the or each set of pixels of the first type by a factor(1+g.L_R/D_R), where g is a scalar multiplier, L_R is the range ofbrightness levels in the set and D_R is a measure of the dynamic rangeof brightness levels in the image.

D_R may be defined as (1+P_MAX−P_MIN) where P_MAX is the maximumbrightness level and P_MIN is the minimum brightness level.

More preferably, however, D_R is defined as (1+P_MAX−P_MIN) where P_MAXis the maximum initial brightness level and P_MIN is the minimum initialbrightness level exhibited by at least a predetermined percentage ofsaid pixels, said predetermined percentage being less than 100%.Alternatively, preferably D_R is defined as (1+P_MAX−P_MIN) where P_MINis the minimum initial brightness level and P_MAX is the maximum initialbrightness level exhibited by at least a predetermined percentage ofsaid pixels, said predetermined percentage being less than 100%. Mostpreferably, D_R is defined as (1 +P_MAX−P_MIN), where P_MIN is theminimum initial brightness level exhibited by at least a firstpredetermined percentage of said pixels, and P_MAX is the maximuminitial brightness level exhibited by at least a second predeterminedpercentage of said pixels, said first predetermined percentage beingless than said second predetermined percentage and each of the first andsecond predetermined percentages being less than 100%.

In an embodiment, said image is one image of a succession of images, theapparatus comprising a scene change detector for detecting changes incontrast between images of the succession images, the apparatus beingarranged to apply the same contrast enhancement to the images of thesuccession of images until a sufficient change in the contrast of theimages is detected, when a different contrast enhancement is applied tofurther images of the succession of images.

According to a third aspect of the present invention, there is provideda method of adjusting the contrast of an image formed of pixels in whicheach pixel has an initial brightness level that is within a range ofbrightness levels between a minimum brightness level and a maximumbrightness level, the method comprising, for at least some of the pixelsin the image: for each of the brightness levels within said range,forming a histogram of the number of said pixels per brightness level inthe original image;

dividing said pixels into at least two types by identifying the or eachregion in the histogram in which a plurality of adjacent ones of saidbrightness levels have more pixels than a threshold number, the pixelsof said plurality of adjacent ones of said brightness levels being afirst type, the remaining pixels being a second type; and, separatelyfor the or each set of pixels of the first type, performing histogramequalisation contrast enhancement on the pixels that make up the set.

The method may comprise smoothing said histogram prior to the dividingstep.

The threshold number is preferably the average of the number of pixelsper brightness level obtained in the counting step multiplied by aconstant greater than 0 and less than or equal to 1.

The method preferably comprises, prior to the contrast enhancement step,expanding the range of brightness levels in the or each set of pixels ofthe first type.

In an embodiment, a linear transformation is applied to the initialbrightness levels of the pixels of the second type.

According to a fourth aspect of the present invention, there is providedapparatus for adjusting the contrast of an image formed of pixels inwhich each pixel has an initial brightness level that is within a rangeof brightness levels between a minimum brightness level and a maximumbrightness level, the apparatus comprising: a histogram formerconstructed and arranged to form, for at least some of the pixels in theimage and for each of the brightness levels within said range, ahistogram of the number of said pixels per brightness level in theoriginal image; a classifier constructed and arranged to divide saidpixels into at least two types by identifying the or each region in thehistogram in which a plurality of adjacent ones of said brightnesslevels have more pixels than a threshold number, the pixels of saidplurality of adjacent ones of said brightness levels being a first type,the remaining pixels being a second type; and, a contrast enhancerconstructed and arranged to perform histogram equalisation contrastenhancement on the pixels that make up the set separately for the oreach set of pixels of the first type.

The apparatus may comprise a smoother constructed and arranged to smoothsaid histogram prior to operation of the classifier.

The threshold number is preferably the average of the number of pixelsper brightness level obtained in the counting step multiplied by aconstant greater than 0 and less than or equal to 1.

The apparatus preferably comprises a range expander constructed andarranged to expand the range of brightness levels in the or each set ofpixels of the first type prior to operation of the contrast enhancer.

In an embodiment, the apparatus comprises a contrast enhancerconstructed and arranged to apply a linear transformation to the initialbrightness levels of the pixels of the second type.

The preferred apparatus and/or method may be incorporated into anyapparatus and/or method that is used to enhance the contrast of adigital image, including for example an image processor used in atelevision set or the like, printers, digital image processing software,etc., etc. The methods described herein may be carried out byappropriate software running on appropriate computer equipment. Thesoftware may be embedded in an integrated circuit, the integratedcircuit being adapted for performing, or for use in the performance of,the relevant processes. Many of the processing steps may be carried outusing software, dedicated hardware (such as ASICs), or a combination.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments of the present invention will now be described by way ofexample with reference to the accompanying drawings, in which:

FIG. 1 and FIG. 2 show schematically two prior art contrast enhancementtechniques;

FIG. 3 schematically shows an overview of an example of a method inaccordance with an embodiment of the present invention;

FIGS. 4 to 8 show schematically detailed steps in an example of a methodaccording to an embodiment of the present invention; and,

FIG. 9 shows schematically an example of a histogram produced duringoperation of a method in accordance with an embodiment of the presentinvention and how the histogram is treated.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Referring first to FIG. 3, in overview a preferred example of anembodiment of the present invention operates as follows. From thebrightness levels of the pixels in the input digital image, a histogramis generated 10. The histogram shows the number of pixels per brightnesslevel or “bin”. In a region extraction step 11, the histogram is dividedinto contiguous regions so that clustered pixel brightness levels areidentified. Each of the regions is defined as a contiguous range ofpixel brightness levels. These clustered pixel brightness levelsindicate the existence of different dominant objects in the image if themagnitude of the relevant part of the histogram is larger than athreshold. The length of each region shows the dynamic range allocatedto those objects in the image.

In order to enhance the contrast in these dominant objects, the dynamicrange allocated to them in the input image is expanded by an expansionfactor in a region correction step 12. The preferred expansion factordepends on the total dynamic range of the brightness levels of the inputimage and the length of the dynamic range. After the expansion operationon each region relating to the dominant objects, these regions arecorrected in the region correction step 12 so that they are orderedaccording to the pixel brightness level without overlap and leaving outany pixel brightness levels in between the regions. In addition, all ofthe regions are shrunk if necessary by the same factor if the union ofthese regions does not fit in the displayable/printable range of pixelbrightness levels. The number of available brightness levels depends onthe display device, printer, etc., and may be for example 256 greylevels.

Using these corrected regions, a mapping is obtained 13. This mappingemploys different types of enhancement depending on the type of theregion. In a preferred embodiment, there are two types of regions. TypeI corresponds to dominant objects and Type II to all remainingnon-dominant objects in the image. For the Type I regions, the preferredmapping function uses histogram equalisation on the input image pixelbrightness levels. Histogram equalisation is carried out so that theoutput pixel brightness levels produced from the dominant object'sextracted region lie in the range that is produced after the correctionoperation corresponding to that region. On the other hand, linearmapping may be used for the Type II or non-dominant object regions sothat the extracted non-dominant regions map to corresponding regions inthe output image.

Using the obtained mapping, contrast in the image is enhanced in step14. The same mapping can be used until a scene change is detected instep 15. In the preferred embodiment, a histogram-based scene changedetector is used to detect scene changes. The same mapping is used untila new image belonging to a new scene as determined by the scene changedetector arrives.

FIG. 4 shows schematically the steps carried out for the histogramgeneration 10 of FIG. 3 and FIG. 9 shows schematically an example of ahistogram produced during operation of a method in accordance with anembodiment of the present invention and how the histogram is treated.

An initial raw histogram value for each pixel brightness level or “bin”is obtained by first counting the number of pixels having each pixelbrightness level in step 20, the original histogram created therebybeing shown as a solid line in FIG. 9. In practice, it is often foundthat the produced input histogram is skewed, typically at least in partbecause of the quantisation that takes place when the image is initiallydigitised. This problem manifests itself by the creation of a skewedhistogram that has large magnitudes at some pixel brightness levels andvery small or zero magnitudes in neighbouring brightness levels. Thiscan be minimised by a smoothing step 21 in which the initial rawhistogram is smoothed. It has been found that a simple window averagingmethod using a low. pass filter may be used for smoothing the initialraw histogram. In an example of a window averaging method, the value forthe number of pixels in a current brightness level or bin is taken to bethe average of a fixed number of bins to the left and to the right ofthe current bin. The boundary conditions are set so that the minimum andmaximum observed pixel brightness levels in the input image are the sameafter the smoothing process. Mirroring can be used to handleout-of-boundary pixel brightness levels during the window averagingstep. In other words, for cases where the current pixel brightness levelis close or equal to zero or the maximum (e.g. 256), the neighbouringbrightness level on one side may be absent. In mirroring, where forexample the current pixel brightness level is equal to zero, the binvalue to the left, equivalent to position −1, is equalised to the valueof the bin position +1; the next bin value to the left, equivalent toposition −2, is equalised to the value of the bin position +2; etc. Thesmoothed original histogram created thereby is shown as a dot-and-dashline in FIG. 9.

FIG. 5 shows schematically a preferred example of the region extractionstep 11 of FIG. 3. The smoothed histogram is input to a level finder 30which first finds the observed dynamic range. This observed dynamicrange is used to calculate a threshold, which in this case is theaverage or uniform level of a uniformly distributed histogram, shown bya dotted line in FIG. 9. The uniform level corresponding to the observeddynamic range is obtained from the following relationship:U _(—) L=s*M*N/D _(—) R

where s is a constant greater than 0 and less than or equal to 1, M isthe number of lines in the input image, N is the number of pixels in aline, and D_R is the observed dynamic range of the input image.

The observed dynamic range D_R is conventionally equal to:D _(—) R=P _(—) MAX−P _(—) MIN+1

where P_MAX is the maximum pixel brightness level and P_MIN is theminimum pixel brightness level observed in the input image. However,more preferably, the value used for P_MIN is the minimum pixelbrightness level exhibited by at least a certain percentage of thepixels in the input image, such as at least 0.05% or 0.1% or so.Similarly, the value used for P_MAX is the maximum pixel brightnesslevel exhibited by at least a certain percentage of the pixels in theinput image, such as at least 99.95% or 99.9% or so. In other words,when determining P_MIN and P_MAX to use in calculating the observeddynamic range, any brightness level having fewer/greater than thecertain percentage of pixels is ignored. This makes the observed dynamicrange D_R more robust to noise and better captures the actual dynamicrange if the histogram tail values are very small.

Whilst the average or uniform level of a uniformly distributed histogramis preferably used as the threshold, other thresholds may be set. Forexample, the threshold may be a certain percentage, say 90%, of theaverage or uniform level of a uniformly distributed histogram.

The uniform level U_L is compared in a comparator 31 against thesmoothed histogram and regions are started and ended as the histogramcrosses the uniform level. Region manager 32 keeps track of the regionsand deletes one point regions where the ending pixel brightness levelcomes immediately after the starting pixel brightness level. (In thesimple example shown in FIG. 9, there is only one Type I region with aType II region on either side. It will be understood however that ingeneral there may be several Type I regions, which are separated fromeach other by Type II regions.)

FIG. 6 shows schematically a preferred example of region correction step12 in FIG. 3. In a range expansion step 40, the observed dynamic rangeis expanded only for dominant objects (i.e. the Type I regions). Thisexpansion depends on the length of region and D_R. The followingrelationship can be used to find the expansion factor (E_Fi) for regioni:E _(—) F _(i)=(1+g*L _(—) R _(i) /D_R)where L_R_(i) is the length of region i, and g is a scalar multiplier. gmay be for example between about 0 and 3. It has been found that a valueof 0.3 for g produces good results.

After the expansion operation, regions are shifted 41 in one directionto avoid overlap between different regions. Once each region is shiftedso that there is no overlap, all of the regions are shifted together sothat the middle pixel brightness levels of the newly obtained dynamicrange and the input dynamic range coincide, if possible.

If after steps 40 and 41 the output dynamic range is larger than theavailable contrast range of the display device, printer, etc., (e.g. 256grey levels), the output dynamic range is rescaled 42 accordingly.

FIG. 7 shows schematically a preferred example of the mapping step 13 ofFIG. 3. Mapping type is selected 50 depending on the type of the region.Input regions are mapped to corresponding output regions obtained bystep 12 in FIG. 3. Whilst in general, any appropriate type of mappingmay be used, preferably Type I regions are mapped using a partialhistogram equalisation 51 in which only the part of the histogram thatbelongs to the or each respective Type I input region is used. In otherwords, for each Type I region, preferably histogram equalisation is usedseparately in which the cumulative distribution function defined only onthat Type I region is used. Type II regions may be mapped to correctedoutput regions using a simpler transformation, such as a lineartransformation 52 of the type y=a*x+b (where a and b are constants) sothat xmin maps to ymin and xmax maps to ymax. Both in Type I and Type IImappings, the mapping for a region is performed so that minimum inputpixel brightness level is mapped to the minimum output brightness levelfor that region, and likewise for the maximum input brightness level ofthat region. Upon the completion of this operation for all regions, thewhole dynamic range of the input image is mapped to the specified outputdynamic range. In the case where a thresholded dynamic range is utilisedas described above, the remaining pixel levels outside the outputdynamic range are located, ensuring that the monotonic order of thepixel brightness levels is maintained. If the contrast range of thedisplay device, printer, etc. is exceeded, then clipping is performed.

FIG. 8 shows schematically a preferred example of the two processingblocks in the scene change detection step 15 of FIG. 3. The preferredscene change detection uses a histogram-based scene change detectionmetric 60. An example of a formula that may be used for the distancemetric D between two different histograms is:${D\left( {h_{1},h_{2}} \right)} = \frac{\sum\limits_{1}^{256}\left( {{h_{1}(i)} - {h_{2}(i)}} \right)^{2}}{\max\left( {{h_{1}(i)},{h_{2}(i)}} \right)}$where h₁ is the histogram of the current image and h₂ is the histogramof a temporally earlier image. h₂ can be the histogram of theimmediately previous image or other temporally earlier images which maybe provided to the scene change metric step 60 by the use of a delayblock 61. This metric therefore detects when there is a “significant”change in the brightness levels of temporally separated images. Theamount of change that triggers a change in the mapping is determined bysetting an appropriate value for D.

When the cumulative distribution function is created from the histogramduring the histogram equalisation of the Type I regions, as in the priorart it is necessary to quantise or digitise the cumulative distributionfunction. The effect of this is that some brightness levels that aredifferent in the input image are mapped to the same output brightnesslevel, which implies a loss of (potential) detail for enhanced outputimage. Accordingly, in a variation, a histogram dithering method for thehistogram equalisation is used. Upon obtaining the cumulativedistribution function from a histogram, it is not quantised to aninteger but rather kept as a floating-point number of a specifiedprecision, say a.b where a is the integer part, and b is the fractionalpart. The output histogram ho is. created from input histogram hi by theformula below at each signal pixel level m:${h_{o}(m)} = {{\sum\limits_{1}^{R}{{h_{i}(n)}*{I\left( {m = {{floor}\quad\left( {{{CDF}(n)}*R} \right)}} \right)}}} + {\sum\limits_{1}^{R}{{h_{i}(n)}*\left( {{m - {{floor}\quad\left( {{CDF}(n)} \right)*{I\left( {m = {{ceil}\left( {{{CDF}(n)}*R} \right)}} \right)}}},} \right.}}}$where CDF(.) is the cumulative distribution function derived from theinput image, R is the maximum number of pixel signal levels displayableby the display device or printer, etc., ceil(.) rounds up to thesmallest larger integer, and floor(.) rounds down to the largest smallerinteger. After obtaining the output histogram, a mapping is found sothat obtained output histogram will be approximately matched using forexample a histogram matching algorithm as given the book by R. C.Gonzalez & Richard E. Woods, entitled “Digital Image Processing”,Prentice Hall, New Jersey, 2001.

Embodiments of the present invention have been described with particularreference to the examples illustrated. However, it will be appreciatedthat variations and modifications may be made to the examples describedwithin the scope of the present invention.

1. A method of adjusting the contrast of an image formed of pixels inwhich each pixel has an initial brightness level that is within a rangeof brightness levels between a minimum brightness level and a maximumbrightness level, the method comprising, for at least some of the pixelsin the image: for each of the brightness levels within said range,counting the number of said pixels that have the same initial brightnesslevel; dividing said pixels into at least two types by identifying theor each set of pixels having initial brightness levels in which each ofa plurality of adjacent ones of said brightness levels has more pixelsthan a. threshold number, the pixels of said plurality of adjacent onesof said brightness levels being a first type, the remaining pixels beinga second type; and, separately for the or each set of pixels of thefirst type, performing contrast enhancement on the pixels that make upthe set.
 2. A method according to claim 1, wherein the contrastenhancement that is performed on the pixels that make up the or each setof pixels of the first type is histogram equalisation.
 3. A methodaccording to claim 1, wherein the method is carried out on all pixels inthe image.
 4. A method according to claim 1, wherein in the countingstep, a histogram is formed in which the number of pixels per brightnesslevel is indicated, and comprising smoothing said histogram prior to thedividing step.
 5. A method according to claim 4, wherein the smoothingis carried out by passing the values of the histogram through a low passfilter.
 6. A method according to claim 4, wherein the minimum andmaximum brightness levels in said histogram after smoothing are the sameas the maximum and minimum initial brightness levels of said pixels. 7.A method according to claim 1, wherein the threshold number is theaverage of the number of pixels per brightness level obtained in thecounting step multiplied by a constant greater than 0 and less than orequal to
 1. 8. A method according to claim 1, comprising applying alinear transformation to the initial brightness levels of the pixels ofthe second type.
 9. A method according to claim 1, comprising, prior tothe contrast enhancement step, expanding the range of brightness levelsin the or each set of pixels of the first type.
 10. A method accordingto claim 9, comprising expanding the range of brightness levels in theor each set of pixels of the first type by a factor (1+g.L_R/D_R), whereg is a scalar multiplier, L_R is the range of brightness levels in theset and D_R is a measure of the dynamic range of brightness levels inthe image.
 11. A method according to claim 10, wherein D_R is defined as(1+P_MAX−P_MIN) where P_MAX is the maximum brightness level and P_MIN isthe minimum brightness level.
 12. A method according to claim 10,wherein D_R is defined as (1+P_MAX−P_MIN) where P_MAX is the maximuminitial brightness level and P_MIN is the minimum initial brightnesslevel exhibited by at least a predetermined percentage of said pixels,said predetermined percentage being less than 100%.
 13. A methodaccording to claim 10, wherein D_R is defined as (1+P_MAX−P_MIN) whereP_MIN is the minimum initial brightness level and P_MAX is the maximuminitial brightness level exhibited by at least a predeterminedpercentage of said pixels, said predetermined percentage being less than100%.
 14. A method according to claim 10, wherein D_R is defined as(1+P_MAX−P_MIN), where P_MIN is the minimum initial brightness levelexhibited by at least a first predetermined percentage of said pixels,and P_MAX is the maximum initial brightness level exhibited by at leasta second predetermined percentage of said pixels, said firstpredetermined percentage being less than said second predeterminedpercentage and each of the first and second predetermined percentagesbeing less than 100%.
 15. A method according to claim 1, wherein saidimage is one image of a succession of images, the method being appliedto the images of the succession of images using the same contrastenhancement until a sufficient change in the contrast of the images isdetected, when a different contrast enhancement is applied to furtherimages of the succession of images.
 16. Apparatus for adjusting thecontrast of an image formed of pixels in which each pixel has an initialbrightness level that is within a range of brightness levels between aminimum brightness level and a maximum brightness level, the apparatuscomprising: a counter constructed and arranged to count, for at leastsome of the pixels in the image and for each of the brightness levelswithin said range, the number of said pixels that have the same initialbrightness level; a classifier constructed and arranged to divide saidpixels into at least two types by identifying the or each set of pixelshaving initial brightness levels in which each of a plurality ofadjacent ones of said brightness levels has more pixels than a thresholdnumber, the pixels of said plurality of adjacent ones of said brightnesslevels being a first type, the remaining pixels being a second type;and, a contrast enhancer constructed and arranged to perform contrastenhancement separately on the or each set of pixels of the first type.17. Apparatus according to claim 16, wherein the contrast enhancer isarranged such that the contrast enhancement that is performed on thepixels that make up the or each set of pixels of the first type ishistogram equalisation.
 18. Apparatus according to claim 16, wherein theapparatus is arranged to operate on all pixels in the image. 19.Apparatus according to claim 16, wherein the counter is arranged to forma histogram in which the number of pixels per brightness level isindicated, the apparatus comprising a smoother constructed and arrangedto smooth said histogram prior to operation of the classifier. 20.Apparatus according to claim 19, wherein the smoother is arranged tooperate by passing the values of the histogram through a low passfilter.
 21. Apparatus according to claim 19, wherein the smoother isarranged so that the minimum and maximum brightness levels in saidhistogram after smoothing are the same as the maximum and minimuminitial brightness levels of said pixels.
 22. Apparatus according toclaim 16, wherein the threshold number is the average of the number ofpixels per brightness level obtained in the counting step multiplied bya constant greater than 0 and less than or equal to
 1. 23. Apparatusaccording to claim 16, comprising a contrast enhancer constructed andarranged to apply a linear transformation to the initial brightnesslevels of the pixels of the second type.
 24. Apparatus according toclaim 16, comprising a range expander constructed and arranged to expandthe range of brightness levels in the or each set of pixels of the firsttype prior to operation of the contrast enhancer.
 25. Apparatusaccording to claim 24, wherein the range expander is arranged to expandthe range of brightness levels in the or each set of pixels of the firsttype by a factor (1+g.L_R/D_R), where g is a scalar multiplier, L_R isthe range of brightness levels in the set and D_R is a measure of thedynamic range of brightness levels in the image.
 26. Apparatus accordingto claim 25, wherein D_R is defined as (1+P_MAX−P_MIN) where P_MAX isthe maximum brightness level and P_MIN is the minimum brightness level.27. Apparatus according to claim 25, wherein D_R is defined as(1+P_MAX−P_MIN) where P_MAX is the maximum initial brightness level andP_MIN is the minimum initial brightness level exhibited by at least apredetermined percentage of said pixels, said predetermined percentagebeing less than 100%.
 28. Apparatus according to claim 25, wherein D_Ris defined as (1+P_MAX−P_MIN) where P_MIN is the minimum initialbrightness level and P_MAX is the maximum initial brightness levelexhibited by at least a predetermined percentage of said pixels, saidpredetermined percentage being less than 100%.
 29. Apparatus accordingto claim 25, wherein D_R is defined as (1+P_MAX−P_MIN), where P_MIN isthe minimum initial brightness level exhibited by at least a firstpredetermined percentage of said pixels, and P_MAX is the maximuminitial brightness level exhibited by at least a second predeterminedpercentage of said pixels, said first predetermined percentage beingless than said second predetermined percentage and each of the first andsecond predetermined percentages being less than 100%.
 30. Apparatusaccording to claim 16, wherein said image is one image of a successionof images, the apparatus comprising a scene change detector fordetecting changes in contrast between images of the succession images,the apparatus being arranged to apply the same contrast enhancement tothe images of the succession of images until a sufficient change in thecontrast of the images is detected, when a different contrastenhancement is applied to further images of the succession of images.31. A method of adjusting the contrast of an image formed of pixels inwhich each pixel has an initial brightness level that is within a rangeof brightness levels between a minimum brightness level and a maximumbrightness level, the method comprising, for at least some of the pixelsin the image: for each of the brightness levels within said range,forming a histogram of the number of said pixels per brightness level inthe original image; dividing said pixels into at least two types byidentifying the or each region in the histogram in which a plurality ofadjacent ones of said brightness levels have more pixels than athreshold number, the pixels of said plurality of adjacent ones of saidbrightness levels being a first type, the remaining pixels being asecond type; and, separately for the or each set of pixels of the firsttype, performing histogram equalisation contrast enhancement on thepixels that make up the set.
 32. A method according to claim 31,comprising smoothing said histogram prior to the dividing step.
 33. Amethod according claim 31, wherein the threshold number is the averageof the number of pixels per brightness level obtained in the countingstep multiplied by a constant greater than 0 and less than or equalto
 1. 34. A method according to claim 31, comprising, prior to thecontrast enhancement step, expanding the range of brightness levels inthe or each set of pixels of the first type.
 35. A method according toclaim 31, comprising applying a linear transformation to the initialbrightness levels of the pixels of the second type.
 36. Apparatus foradjusting the contrast of an image formed of pixels in which each pixelhas an initial brightness level that is within a range of brightnesslevels between a minimum brightness level and a maximum brightnesslevel, the apparatus comprising: a histogram former constructed andarranged to form, for at least some of the pixels in the image and foreach of the brightness levels within said range, a histogram of thenumber of said pixels per brightness level in the original image; aclassifier constructed and arranged to divide said pixels into at leasttwo types by identifying the or each region in the histogram in which aplurality of adjacent ones of said brightness levels have more pixelsthan a threshold number, the pixels of said plurality of adjacent onesof said brightness levels being a first type, the remaining pixels beinga second type; and, a contrast enhancer constructed and arranged toperform histogram equalisation contrast enhancement on the pixels thatmake up the set separately for the or each set of pixels of the firsttype.
 37. Apparatus method according to claim 36, comprising a smootherconstructed and arranged to smooth said histogram prior to operation ofthe classifier.
 38. Apparatus according claim 36, wherein the thresholdnumber is the average of the number of pixels per brightness levelobtained in the counting step multiplied by a constant greater than 0and less than or equal to
 1. 39. Apparatus according to claim 36,comprising a range expander constructed and arranged to expand the rangeof brightness levels in the or each set of pixels of the first typeprior to operation of the contrast enhancer.
 40. Apparatus according toclaim 36, comprising a contrast enhancer constructed and arranged toapply a linear transformation to the initial brightness levels of thepixels of the second type.